<?php
namespace Admin\Controller;
use Think\Controller;
class PublicController extends Controller {
    public function index(){
        $this->display();
    }
    public function login(){
    	if(IS_POST){
            // 做一个简单的登录 组合where数组条件 
            $map=I('post.');
            $map['username']=$map['username'];
            $map['password']=md5($map['password']);
            $data=M('Admin')->where($map)->find();
            if (empty($data)) {
                $this->error('账号或密码错误');
            }else{
                $_SESSION['think_adminlte_id']=$data['id'];
                $_SESSION['think_adminlte_name']=$data['username'];
                $this->success('登录成功、前往管理后台',U('Admin/Index/index'));
            }
        } else {
        	$this->display();
        }
    	
    }

    public function logout(){
        session('think_adminlte_id',null);
        session('think_adminlte_name',null);
        $this->success('退出成功、前往登录页面',U('Admin/Public/login'));
    }


}